<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生注册</title>
    <script>
        //用户名
        function isRegisterUserName()
        {
            var s=document.getElementById("username").value;
            var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/;
            if(!patrn.exec(s)){
                document.getElementById("isusername").innerHTML="用户名以字母开头,并包含数字";
            }else {
                document.getElementById("isusername").innerHTML="";
            }
        }
        //密码
        function isPasswd()
        {
            var s=document.getElementById("pwd").value;
            var patrn=/^(\w){6,20}$/;
            if(!patrn.exec(s)){
                document.getElementById("ispwd").innerHTML="请输入6-20位密码";
            }else {
                document.getElementById("ispwd").innerHTML="";
            }

        }
        //手机号码,可含有“-”
        function isMobil(s)
        {
            var s=document.getElementById("phone").value;
            var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
            if(!patrn.exec(s)){
                document.getElementById("isphone").innerHTML="请输入11位手机号码";
            }else {
                document.getElementById("isphone").innerHTML="";
            }

        }
        //用户姓名,1-30个以字母开头的字串
        function isTrueName()
        {
            var s=document.getElementById("name").value;
            var patrn=/^[a-zA-Z]{1,30}$/;
            if(!patrn.exec(s)){
                document.getElementById("isname").innerHTML="姓名格式错误！";
            }else {
                document.getElementById("isname").innerHTML="";
            }

        }
        //Email
        function isEmail() {
            var s=document.getElementById("email").value;
            var patrn=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
            if(!patrn.exec(s)){
                document.getElementById("isemail").innerHTML="Email格式错误！";
            }else {
                document.getElementById("isemail").innerHTML="";
            }
        }

        function getUrl() {
            var username="user3";
            var pwd="password3";
            var url="zuoye3-get.jsp?username="+username+"&"+"pwd="+pwd;
            location.href=url;
        }

    </script>
</head>
<body>
<h2 style="text-align: center">学生注册</h2>
<form name="myform" action="zuoye3-get.jsp" method="post">
    <table style="margin: 0 auto auto 40%">
        <tr>
            <td>姓名：</td>
            <td>
                <input type="text" style="width: 270px" name="name" id="name" onblur="isTrueName()">
                <div id="isname" style="float: right;width: 150px"></div>
            </td>
        </tr>
        <tr>
            <td>性别：</td>
            <td>
                <input type="radio" name="sex" value="男">男
                <input type="radio" name="sex" value="女">女
            </td>
        </tr>
        <tr>
            <td>出生日期：</td>
            <td><input type="date" style="width: 270px" name="birthday" id="birthday"></td>
        </tr>
        <tr>
            <td>学校：</td>
            <td><input type="text" style="width: 270px" name="school" id="school"></td>
        </tr>
        <tr>
            <td>专业：</td>
            <td>
                <select style="width: 270px;height: 25px">
                    <option value="计算机">计算机科学与技术</option>
                    <option value="计开发">计开发</option>
                    <option value="计测试">计测试</option>
                    <option value="物联网">物联网</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>体育特长：</td>
            <td>
                <input type="checkbox" name="ti" value="篮球">篮球
                <input type="checkbox" name="ti" value="足球">足球
                <input type="checkbox" name="ti" value="羽毛球">羽毛球
                <input type="checkbox" name="ti" value="乒乓球">乒乓球
            </td>
        </tr>
        <tr>
            <td>上传照片：</td>
            <td><input type="file"></td>
        </tr>
        <tr>
            <td>邮箱：</td>
            <td>
                <input type="text" style="width: 270px" name="email" id="email" onblur="isEmail()">
                <div id="isemail" style="float: right;width: 150px" ></div>
            </td>
        </tr>
        <tr>
            <td>手机号码：</td>
            <td>
                <input type="text" style="width: 270px" name="phone" id="phone" onblur="isMobil()">
                <div id="isphone" style="float: right;width: 150px"></div>
            </td>
        </tr>
        <tr>
            <td>用户名：</td>
            <td><input type="text" style="width: 270px" name="username" id="username" onblur="isRegisterUserName()">
                <div id="isusername" style="float: right;width: 150px"></div>
            </td>
        </tr>
        <tr>
            <td>密码：</td>
            <td>
                <input type="password" style="width: 270px" name="pwd" id="pwd" onblur="isPasswd()">
                <div id="ispwd" style="float: right;width: 150px"></div>
            </td>
        </tr>
        <tr>
            <td>个人简介：</td>
            <td style="height: 100px"><textarea style="width: 270px;height: 100px" name="mytxt" id="mytxt"> </textarea></td>
        </tr>
        <tr>
            <td style="padding-top: 20px;padding-left: 30%" colspan="2">
                <button type="submit" >提交</button>
                <button type="reset" >重置</button>
            </td>
        </tr>
    </table>
</form>
<a href=javascript:getUrl()>get传值</a>
</body>
</html>
